﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

using log4net;
using KhoiKhoa.Web.Helper;

namespace KhoiKhoa.Web
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{page}", // URL with parameters
                new { controller = "Home", action = "Index", page = string.Empty } // Parameter defaults
            );

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);

            //init log4net configuration
            log4net.Config.XmlConfigurator.Configure();

            string root = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath;
            //string root = System.Web.HttpContext.Current.Request.ApplicationPath;
            if (root.Equals("/"))
                root = string.Empty;
            Application["Root"] = root;

            Dictionary<string, string> QueryStringToViewName = new Dictionary<string, string>(9);
            QueryStringToViewName.Add(Constant.QUERY_STRING_BANG_GIA, "BangBaoGia");
            QueryStringToViewName.Add(Constant.QUERY_STRING_BAT_DONG_SAN, "BatDongSan");
            QueryStringToViewName.Add(Constant.QUERY_STRING_CONG_TRINH_TIEU_BIEU, "CongTrinhTieuBieu");
            QueryStringToViewName.Add(Constant.QUERY_STRING_DICH_VU_TU_VAN, "DichVuTuVan");
            QueryStringToViewName.Add(Constant.QUERY_STRING_HOP_DONG_THIET_KE_MAU, "HopDongThietKeMau");
            QueryStringToViewName.Add(Constant.QUERY_STRING_QUY_TRINH_THIET_KE, "QuyTrinhThietKe");
            QueryStringToViewName.Add(Constant.QUERY_STRING_SO_DO_TO_CHUC, "SoDoToChuc");
            QueryStringToViewName.Add(Constant.QUERY_STRING_TIN_TUC, "TinTuc");
            QueryStringToViewName.Add(Constant.QUERY_STRING_TRANG_CHU, "TrangChu");
            Application["QueryStringToViewName"] = QueryStringToViewName;
        }
    }
}